<!doctype html>
<html>
<head>
<meta charset='UTF-8'><meta name='viewport' content='width=device-width initial-scale=1'>
<title>开放接口文档.md</title><link href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,700,400&subset=latin,latin-ext' rel='stylesheet' type='text/css'><style type='text/css'>html, body {overflow-x: initial !important;}.CodeMirror { height: auto; }
.CodeMirror-scroll { overflow-y: hidden; overflow-x: auto; }
.CodeMirror-lines { padding: 4px 0px; }
.CodeMirror pre { }
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { background-color: white; }
.CodeMirror-gutters { border-right: 1px solid rgb(221, 221, 221); background-color: rgb(247, 247, 247); white-space: nowrap; }
.CodeMirror-linenumbers { }
.CodeMirror-linenumber { padding: 0px 3px 0px 5px; text-align: right; color: rgb(153, 153, 153); }
.CodeMirror div.CodeMirror-cursor { border-left: 1px solid black; z-index: 3; }
.CodeMirror div.CodeMirror-secondarycursor { border-left: 1px solid silver; }
.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor { width: auto; border: 0px; background: rgb(119, 238, 119); z-index: 1; }
.CodeMirror div.CodeMirror-cursor.CodeMirror-overwrite { }
.cm-tab { display: inline-block; }
.cm-s-typora-default .cm-header, .cm-s-typora-default .cm-property { color: rgb(217, 79, 138); }
.cm-s-typora-default pre.cm-header1:not(.cm-atom) :not(.cm-overlay) { font-size: 2rem; line-height: 2rem; }
.cm-s-typora-default pre.cm-header2:not(.cm-atom) :not(.cm-overlay) { font-size: 1.4rem; line-height: 1.4rem; }
.cm-s-typora-default .cm-atom, .cm-s-typora-default .cm-number { color: rgb(149, 132, 134); }
.cm-s-typora-default .cm-table-row, .cm-s-typora-default .cm-block-start { font-family: monospace; }
.cm-s-typora-default .cm-comment, .cm-s-typora-default .cm-code { color: rgb(74, 90, 159); font-family: monospace; }
.cm-s-typora-default .cm-tag { color: rgb(169, 68, 66); }
.cm-s-typora-default .cm-string { color: rgb(126, 134, 169); }
.cm-s-typora-default .cm-link { color: rgb(196, 122, 15); text-decoration: underline; }
.cm-s-typora-default .cm-variable-2, .cm-s-typora-default .cm-variable-1 { color: inherit; }
.cm-s-typora-default .cm-overlay { font-size: 1rem; font-family: monospace; }
.CodeMirror.cm-s-typora-default div.CodeMirror-cursor { border-left: 3px solid rgb(228, 98, 154); }
.cm-s-typora-default .CodeMirror-activeline-background { left: -60px; right: -30px; background: rgba(204, 204, 204, 0.2); }
.cm-s-typora-default .CodeMirror-gutters { border-right: none; background-color: inherit; }
.cm-s-typora-default .cm-trailing-space-new-line::after, .cm-startspace::after, .cm-starttab .cm-tab::after { content: "•"; position: absolute; left: 0px; opacity: 0; font-family: LetterGothicStd, monospace; }
.os-windows .cm-startspace::after, .os-windows .cm-starttab .cm-tab::after { left: -0.1em; }
.cm-starttab .cm-tab::after { content: " "; }
.cm-startspace, .cm-tab, .cm-starttab, .cm-trailing-space-a, .cm-trailing-space-b, .cm-trailing-space-new-line { font-family: monospace; position: relative; }
.cm-s-typora-default .cm-trailing-space-new-line::after { content: "↓"; opacity: 0.3; }
.cm-s-inner .cm-keyword { color: rgb(119, 0, 136); }
.cm-s-inner .cm-atom, .cm-s-inner.cm-atom { color: rgb(34, 17, 153); }
.cm-s-inner .cm-number { color: rgb(17, 102, 68); }
.cm-s-inner .cm-def { color: rgb(0, 0, 255); }
.cm-s-inner .cm-variable { color: black; }
.cm-s-inner .cm-variable-2 { color: rgb(0, 85, 170); }
.cm-s-inner .cm-variable-3 { color: rgb(0, 136, 85); }
.cm-s-inner .cm-property { color: black; }
.cm-s-inner .cm-operator { color: rgb(152, 26, 26); }
.cm-s-inner .cm-comment, .cm-s-inner.cm-comment { color: rgb(170, 85, 0); }
.cm-s-inner .cm-string { color: rgb(170, 17, 17); }
.cm-s-inner .cm-string-2 { color: rgb(255, 85, 0); }
.cm-s-inner .cm-meta { color: rgb(85, 85, 85); }
.cm-s-inner .cm-qualifier { color: rgb(85, 85, 85); }
.cm-s-inner .cm-builtin { color: rgb(51, 0, 170); }
.cm-s-inner .cm-bracket { color: rgb(153, 153, 119); }
.cm-s-inner .cm-tag { color: rgb(17, 119, 0); }
.cm-s-inner .cm-attribute { color: rgb(0, 0, 204); }
.cm-s-inner .cm-header, .cm-s-inner.cm-header { color: blue; }
.cm-s-inner .cm-quote, .cm-s-inner.cm-quote { color: rgb(0, 153, 0); }
.cm-s-inner .cm-hr, .cm-s-inner.cm-hr { color: rgb(153, 153, 153); }
.cm-s-inner .cm-link, .cm-s-inner.cm-link { color: rgb(0, 0, 204); }
.cm-negative { color: rgb(221, 68, 68); }
.cm-positive { color: rgb(34, 153, 34); }
.cm-header, .cm-strong { font-weight: bold; }
.cm-del { text-decoration: line-through; }
.cm-em { font-style: italic; }
.cm-link { text-decoration: underline; }
.cm-error { color: rgb(255, 0, 0); }
.cm-invalidchar { color: rgb(255, 0, 0); }
.cm-constant { color: rgb(38, 139, 210); }
.cm-defined { color: rgb(181, 137, 0); }
div.CodeMirror span.CodeMirror-matchingbracket { color: rgb(0, 255, 0); }
div.CodeMirror span.CodeMirror-nonmatchingbracket { color: rgb(255, 34, 34); }
.cm-s-inner .CodeMirror-activeline-background { background: inherit; }
.CodeMirror { position: relative; overflow: hidden; }
.CodeMirror-scroll { margin-bottom: -30px; margin-right: -30px; padding-bottom: 30px; padding-right: 30px; height: 100%; outline: none; position: relative; box-sizing: content-box; }
.CodeMirror-sizer { position: relative; }
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { position: absolute; z-index: 6; display: none; }
.CodeMirror-vscrollbar { right: 0px; top: 0px; overflow-x: hidden; overflow-y: scroll; }
.CodeMirror-hscrollbar { bottom: 0px; left: 0px; overflow-y: hidden; overflow-x: scroll; }
.CodeMirror-scrollbar-filler { right: 0px; bottom: 0px; }
.CodeMirror-gutter-filler { left: 0px; bottom: 0px; }
.CodeMirror-gutters { position: absolute; left: 0px; top: 0px; padding-bottom: 30px; z-index: 3; }
.CodeMirror-gutter { white-space: normal; height: 100%; box-sizing: content-box; padding-bottom: 30px; margin-bottom: -32px; display: inline-block; }
.CodeMirror-gutter-elt { position: absolute; cursor: default; z-index: 4; }
.CodeMirror-lines { cursor: text; }
.CodeMirror pre { border-radius: 0px; border-width: 0px; background: transparent; font-family: inherit; font-size: inherit; margin: 0px; white-space: pre; word-wrap: normal; color: inherit; z-index: 2; position: relative; overflow: visible; }
.CodeMirror-wrap pre { word-wrap: break-word; white-space: pre-wrap; word-break: normal; }
.CodeMirror-code pre { border-right: 30px solid transparent; width: fit-content; }
.CodeMirror-wrap .CodeMirror-code pre { border-right: none; width: auto; }
.CodeMirror-linebackground { position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px; z-index: 0; }
.CodeMirror-linewidget { position: relative; z-index: 2; overflow: auto; }
.CodeMirror-widget { }
.CodeMirror-wrap .CodeMirror-scroll { overflow-x: hidden; }
.CodeMirror-measure { position: absolute; width: 100%; height: 0px; overflow: hidden; visibility: hidden; }
.CodeMirror-measure pre { position: static; }
.CodeMirror div.CodeMirror-cursor { position: absolute; visibility: hidden; border-right: none; width: 0px; }
.CodeMirror div.CodeMirror-cursor { visibility: hidden; }
.CodeMirror-focused div.CodeMirror-cursor { visibility: inherit; }
.CodeMirror-selected { background: rgb(217, 217, 217); }
.CodeMirror-focused .CodeMirror-selected { background: rgb(215, 212, 240); }
.cm-searching { background: rgba(255, 255, 0, 0.4); }
.CodeMirror span { }
@media print { 
  .CodeMirror div.CodeMirror-cursor { visibility: hidden; }
}
.CodeMirror-lint-markers { width: 16px; }
.CodeMirror-lint-tooltip { background-color: infobackground; border: 1px solid black; border-radius: 4px; color: infotext; font-family: monospace; overflow: hidden; padding: 2px 5px; position: fixed; white-space: pre-wrap; z-index: 10000; max-width: 600px; opacity: 0; transition: opacity 0.4s; font-size: 0.8em; }
.CodeMirror-lint-mark-error, .CodeMirror-lint-mark-warning { background-position: left bottom; background-repeat: repeat-x; }
.CodeMirror-lint-mark-error { background-image: url(""); }
.CodeMirror-lint-marker-error, .CodeMirror-lint-marker-warning { background-position: center center; background-repeat: no-repeat; cursor: pointer; display: inline-block; height: 16px; width: 16px; vertical-align: middle; position: relative; }
.CodeMirror-lint-message-error, .CodeMirror-lint-message-warning { padding-left: 18px; background-position: left top; background-repeat: no-repeat; }
.CodeMirror-lint-marker-error, .CodeMirror-lint-message-error { background-image: url(""); }
.CodeMirror-lint-marker-warning, .CodeMirror-lint-message-warning { background-image: url(""); }
.CodeMirror-lint-marker-multiple { background-image: url(""); background-repeat: no-repeat; background-position: right bottom; width: 100%; height: 100%; }


html { font-size: 14px; background-color: rgb(255, 255, 255); color: rgb(51, 51, 51); }
body { margin: 0px; padding: 0px; height: auto; bottom: 0px; top: 0px; left: 0px; right: 0px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 1rem; line-height: 1.42857; overflow-x: hidden; background: inherit; }
a:active, a:hover { outline: 0px; }
.in-text-selection, ::selection { background: rgb(181, 214, 252); text-shadow: none; }
#write { margin: 0px auto; height: auto; width: inherit; word-break: normal; word-wrap: break-word; position: relative; padding-bottom: 70px; white-space: pre-wrap; overflow-x: auto; }
.for-image #write { padding-left: 8px; padding-right: 8px; }
body.typora-export { padding-left: 30px; padding-right: 30px; }
@media screen and (max-width: 500px) { 
  body.typora-export { padding-left: 0px; padding-right: 0px; }
  .CodeMirror-sizer { margin-left: 0px !important; }
  .CodeMirror-gutters { display: none !important; }
}
.typora-export #write { margin: 0px auto; }
#write > p:first-child, #write > ul:first-child, #write > ol:first-child, #write > pre:first-child, #write > blockquote:first-child, #write > div:first-child, #write > table:first-child { margin-top: 30px; }
#write li > table:first-child { margin-top: -20px; }
img { max-width: 100%; vertical-align: middle; }
input, button, select, textarea { color: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; font-family: inherit; }
input[type="checkbox"], input[type="radio"] { line-height: normal; padding: 0px; }
::before, ::after, * { box-sizing: border-box; }
#write p, #write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write div, #write pre { width: inherit; }
#write p, #write h1, #write h2, #write h3, #write h4, #write h5, #write h6 { position: relative; }
h1 { font-size: 2rem; }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.6rem; }
h4 { font-size: 1.4rem; }
h5 { font-size: 1.2rem; }
h6 { font-size: 1rem; }
p { -webkit-margin-before: 1rem; -webkit-margin-after: 1rem; -webkit-margin-start: 0px; -webkit-margin-end: 0px; }
.mathjax-block { margin-top: 0px; margin-bottom: 0px; -webkit-margin-before: 0rem; -webkit-margin-after: 0rem; }
.hidden { display: none; }
.md-blockmeta { color: rgb(204, 204, 204); font-weight: bold; font-style: italic; }
a { cursor: pointer; }
#write input[type="checkbox"] { cursor: pointer; width: inherit; height: inherit; margin: 4px 0px 0px; }
tr { break-inside: avoid; break-after: auto; }
thead { display: table-header-group; }
table { border-collapse: collapse; border-spacing: 0px; width: 100%; overflow: auto; break-inside: auto; text-align: left; }
table.md-table td { min-width: 80px; }
.CodeMirror-gutters { border-right: 0px; background-color: inherit; }
.CodeMirror { text-align: left; }
.CodeMirror-placeholder { opacity: 0.3; }
.CodeMirror pre { padding: 0px 4px; }
.CodeMirror-lines { padding: 0px; }
div.hr:focus { cursor: none; }
pre { white-space: pre-wrap; }
.CodeMirror-gutters { margin-right: 4px; }
.md-fences { font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; overflow: visible; white-space: pre; background: inherit; position: relative !important; }
.md-diagram-panel { width: 100%; margin-top: 10px; text-align: center; padding-top: 0px; padding-bottom: 8px; overflow-x: auto; }
.md-fences .CodeMirror.CodeMirror-wrap { top: -1.6em; margin-bottom: -1.6em; }
.md-fences.mock-cm { white-space: pre-wrap; }
.show-fences-line-number .md-fences { padding-left: 0px; }
.show-fences-line-number .md-fences.mock-cm { padding-left: 40px; }
.footnotes { opacity: 0.8; font-size: 0.9rem; padding-top: 1em; padding-bottom: 1em; }
.footnotes + .footnotes { margin-top: -1em; }
.md-reset { margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: top; background: transparent; text-decoration: none; text-shadow: none; float: none; position: static; width: auto; height: auto; white-space: nowrap; cursor: inherit; -webkit-tap-highlight-color: transparent; line-height: normal; font-weight: normal; text-align: left; box-sizing: content-box; direction: ltr; }
li div { padding-top: 0px; }
blockquote { margin: 1rem 0px; }
li p, li .mathjax-block { margin: 0.5rem 0px; }
li { margin: 0px; position: relative; }
blockquote > :last-child { margin-bottom: 0px; }
blockquote > :first-child { margin-top: 0px; }
.footnotes-area { color: rgb(136, 136, 136); margin-top: 0.714rem; padding-bottom: 0.143rem; }
@media print { 
  html, body { height: 100%; }
  .typora-export * { -webkit-print-color-adjust: exact; }
  h1, h2, h3, h4, h5, h6 { break-after: avoid-page; orphans: 2; }
  p { orphans: 4; }
  html.blink-to-pdf { font-size: 13px; }
  .typora-export #write { padding-left: 1cm; padding-right: 1cm; }
  .typora-export #write::after { height: 0px; }
  @page { margin: 20mm 0mm; }
}
.footnote-line { margin-top: 0.714em; font-size: 0.7em; }
a img, img a { cursor: pointer; }
pre.md-meta-block { font-size: 0.8rem; min-height: 2.86rem; white-space: pre-wrap; background: rgb(204, 204, 204); display: block; overflow-x: hidden; }
p .md-image:only-child { display: inline-block; width: 100%; text-align: center; }
#write .MathJax_Display { margin: 0.8em 0px 0px; }
.mathjax-block { white-space: pre; overflow: hidden; width: 100%; }
p + .mathjax-block { margin-top: -1.143rem; }
.mathjax-block:not(:empty)::after { display: none; }
[contenteditable="true"]:active, [contenteditable="true"]:focus { outline: none; box-shadow: none; }
.task-list { list-style-type: none; }
.task-list-item { position: relative; padding-left: 1em; }
.task-list-item input { position: absolute; top: 0px; left: 0px; }
.math { font-size: 1rem; }
.md-toc { min-height: 3.58rem; position: relative; font-size: 0.9rem; border-radius: 10px; }
.md-toc-content { position: relative; margin-left: 0px; }
.md-toc::after, .md-toc-content::after { display: none; }
.md-toc-item { display: block; color: rgb(65, 131, 196); text-decoration: none; }
.md-toc-inner:hover { }
.md-toc-inner { display: inline-block; cursor: pointer; }
.md-toc-h1 .md-toc-inner { margin-left: 0px; font-weight: bold; }
.md-toc-h2 .md-toc-inner { margin-left: 2em; }
.md-toc-h3 .md-toc-inner { margin-left: 4em; }
.md-toc-h4 .md-toc-inner { margin-left: 6em; }
.md-toc-h5 .md-toc-inner { margin-left: 8em; }
.md-toc-h6 .md-toc-inner { margin-left: 10em; }
@media screen and (max-width: 48em) { 
  .md-toc-h3 .md-toc-inner { margin-left: 3.5em; }
  .md-toc-h4 .md-toc-inner { margin-left: 5em; }
  .md-toc-h5 .md-toc-inner { margin-left: 6.5em; }
  .md-toc-h6 .md-toc-inner { margin-left: 8em; }
}
a.md-toc-inner { font-size: inherit; font-style: inherit; font-weight: inherit; line-height: inherit; }
.footnote-line a:not(.reversefootnote) { color: inherit; }
.md-attr { display: none; }
.md-fn-count::after { content: "."; }
.md-tag { opacity: 0.5; }
.md-comment { color: rgb(162, 127, 3); opacity: 0.8; font-family: monospace; }
code { text-align: left; }
h1 .md-tag, h2 .md-tag, h3 .md-tag, h4 .md-tag, h5 .md-tag, h6 .md-tag { font-weight: initial; opacity: 0.35; }
a.md-print-anchor { border-width: initial !important; border-style: none !important; border-color: initial !important; display: inline-block !important; position: absolute !important; width: 1px !important; right: 0px !important; outline: none !important; background: transparent !important; text-decoration: initial !important; text-shadow: initial !important; }
.md-inline-math .MathJax_SVG .noError { display: none !important; }
.mathjax-block .MathJax_SVG_Display { text-align: center; margin: 1em 0em; position: relative; text-indent: 0px; max-width: none; max-height: none; min-height: 0px; min-width: 100%; width: auto; display: block !important; }
.MathJax_SVG_Display, .md-inline-math .MathJax_SVG_Display { width: auto; margin: inherit; display: inline-block !important; }
.MathJax_SVG .MJX-monospace { font-family: monospace; }
.MathJax_SVG .MJX-sans-serif { font-family: sans-serif; }
.MathJax_SVG { display: inline; font-style: normal; font-weight: normal; line-height: normal; zoom: 90%; text-indent: 0px; text-align: left; text-transform: none; letter-spacing: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px; }
.MathJax_SVG * { transition: none; }


@font-face { font-family: "Open Sans"; font-style: normal; font-weight: normal; src: local("Open Sans Regular"), url("./github/400.woff") format("woff"); }
@font-face { font-family: "Open Sans"; font-style: italic; font-weight: normal; src: local("Open Sans Italic"), url("./github/400i.woff") format("woff"); }
@font-face { font-family: "Open Sans"; font-style: normal; font-weight: bold; src: local("Open Sans Bold"), url("./github/700.woff") format("woff"); }
@font-face { font-family: "Open Sans"; font-style: italic; font-weight: bold; src: local("Open Sans Bold Italic"), url("./github/700i.woff") format("woff"); }
html { font-size: 16px; }
body { font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; color: rgb(51, 51, 51); line-height: 1.6; }
#write { max-width: 860px; margin: 0px auto; padding: 20px 30px 100px; }
#write > ul:first-child, #write > ol:first-child { margin-top: 30px; }
body > :first-child { margin-top: 0px !important; }
body > :last-child { margin-bottom: 0px !important; }
a { color: rgb(65, 131, 196); }
h1, h2, h3, h4, h5, h6 { position: relative; margin-top: 1rem; margin-bottom: 1rem; font-weight: bold; line-height: 1.4; cursor: text; }
h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor, h5:hover a.anchor, h6:hover a.anchor { text-decoration: none; }
h1 tt, h1 code { font-size: inherit; }
h2 tt, h2 code { font-size: inherit; }
h3 tt, h3 code { font-size: inherit; }
h4 tt, h4 code { font-size: inherit; }
h5 tt, h5 code { font-size: inherit; }
h6 tt, h6 code { font-size: inherit; }
h1 { padding-bottom: 0.3em; font-size: 2.25em; line-height: 1.2; border-bottom: 1px solid rgb(238, 238, 238); }
h2 { padding-bottom: 0.3em; font-size: 1.75em; line-height: 1.225; border-bottom: 1px solid rgb(238, 238, 238); }
h3 { font-size: 1.5em; line-height: 1.43; }
h4 { font-size: 1.25em; }
h5 { font-size: 1em; }
h6 { font-size: 1em; color: rgb(119, 119, 119); }
p, blockquote, ul, ol, dl, table { margin: 0.8em 0px; }
li > ol, li > ul { margin: 0px; }
hr { height: 4px; padding: 0px; margin: 16px 0px; background-color: rgb(231, 231, 231); border-width: 0px 0px 1px; border-style: none none solid; border-top-color: initial; border-right-color: initial; border-left-color: initial; border-image: initial; overflow: hidden; box-sizing: content-box; border-bottom-color: rgb(221, 221, 221); }
body > h2:first-child { margin-top: 0px; padding-top: 0px; }
body > h1:first-child { margin-top: 0px; padding-top: 0px; }
body > h1:first-child + h2 { margin-top: 0px; padding-top: 0px; }
body > h3:first-child, body > h4:first-child, body > h5:first-child, body > h6:first-child { margin-top: 0px; padding-top: 0px; }
a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 { margin-top: 0px; padding-top: 0px; }
h1 p, h2 p, h3 p, h4 p, h5 p, h6 p { margin-top: 0px; }
li p.first { display: inline-block; }
ul, ol { padding-left: 30px; }
ul:first-child, ol:first-child { margin-top: 0px; }
ul:last-child, ol:last-child { margin-bottom: 0px; }
blockquote { border-left: 4px solid rgb(221, 221, 221); padding: 0px 15px; color: rgb(119, 119, 119); }
blockquote blockquote { padding-right: 0px; }
table { padding: 0px; word-break: initial; }
#write { overflow-x: auto; }
table tr { border-top: 1px solid rgb(204, 204, 204); background-color: white; margin: 0px; padding: 0px; }
table tr:nth-child(2n) { background-color: rgb(248, 248, 248); }
table tr th { font-weight: bold; border: 1px solid rgb(204, 204, 204); text-align: left; margin: 0px; padding: 6px 13px; }
table tr td { border: 1px solid rgb(204, 204, 204); text-align: left; margin: 0px; padding: 6px 13px; }
table tr th:first-child, table tr td:first-child { margin-top: 0px; }
table tr th:last-child, table tr td:last-child { margin-bottom: 0px; }
.CodeMirror-gutters { border-right: 1px solid rgb(221, 221, 221); }
.md-fences, code, tt { border: 1px solid rgb(221, 221, 221); background-color: rgb(248, 248, 248); border-radius: 3px; font-family: Consolas, "Liberation Mono", Courier, monospace; padding: 2px 4px 0px; font-size: 0.9em; }
.md-fences { margin-bottom: 15px; margin-top: 15px; padding: 8px 1em 6px; }
.task-list { padding-left: 0px; }
.task-list-item { padding-left: 32px; }
.task-list-item input { top: 3px; left: 8px; }
@media screen and (min-width: 914px) { 
}
@media print { 
  html { font-size: 13px; }
  table, pre { break-inside: avoid; }
  pre { word-wrap: break-word; }
}
.md-fences { background-color: rgb(248, 248, 248); }
#write pre.md-meta-block { padding: 1rem; font-size: 85%; line-height: 1.45; background-color: rgb(247, 247, 247); border: 0px; border-radius: 3px; color: rgb(119, 119, 119); margin-top: 0px !important; }
.mathjax-block > .code-tooltip { bottom: 0.375rem; }
#write > h3.md-focus::before { left: -1.5625rem; top: 0.375rem; }
#write > h4.md-focus::before { left: -1.5625rem; top: 0.285714rem; }
#write > h5.md-focus::before { left: -1.5625rem; top: 0.285714rem; }
#write > h6.md-focus::before { left: -1.5625rem; top: 0.285714rem; }
.md-image > .md-meta { border: 1px solid rgb(221, 221, 221); background-color: rgb(248, 248, 248); border-radius: 3px; font-family: Consolas, "Liberation Mono", Courier, monospace; padding: 2px 4px 0px; font-size: 0.9em; color: inherit; }
.md-tag { color: inherit; }
.md-toc { margin-top: 20px; padding-bottom: 20px; }
#typora-quick-open { border: 1px solid rgb(221, 221, 221); background-color: rgb(248, 248, 248); }
#typora-quick-open-item { background-color: rgb(250, 250, 250); border-color: rgb(254, 254, 254) rgb(229, 229, 229) rgb(229, 229, 229) rgb(238, 238, 238); border-style: solid; border-width: 1px; }
#md-notification::before { top: 10px; }
.on-focus-mode blockquote { border-left-color: rgba(85, 85, 85, 0.117647); }
header, .context-menu, .megamenu-content, footer { font-family: "Segoe UI", Arial, sans-serif; }






</style>
</head>
<body class='typora-export' >
<div  id='write'  class = 'is-node'><div class='md-toc' mdtype='toc'><p class="md-toc-content"><span class="md-toc-item md-toc-h1" data-ref="c40448"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c40448">接口概要</a></span><span class="md-toc-item md-toc-h1" data-ref="c40495"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c40495">接口列表</a></span><span class="md-toc-item md-toc-h2" data-ref="c40496"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c40496">上下文控制</a></span><span class="md-toc-item md-toc-h2" data-ref="c40498"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c40498">低频数据接口</a></span><span class="md-toc-item md-toc-h2" data-ref="c40500"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c40500">订阅接口</a></span><span class="md-toc-item md-toc-h2" data-ref="c40503"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c40503">高频数据接口</a></span><span class="md-toc-item md-toc-h2" data-ref="c40505"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c40505">回调处理基类</a></span><span class="md-toc-item md-toc-h1" data-ref="c40509"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c40509">接口说明</a></span><span class="md-toc-item md-toc-h2" data-ref="c40511"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c40511">参数类型定义</a></span><span class="md-toc-item md-toc-h2" data-ref="c40677"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c40677">详细说明</a></span><span class="md-toc-item md-toc-h3" data-ref="c40678"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c40678">实例化上下文对象</a></span><span class="md-toc-item md-toc-h3" data-ref="c40691"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c40691">启动推送接收 start</a></span><span class="md-toc-item md-toc-h3" data-ref="c40699"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c40699">停止推送接收 stop</a></span><span class="md-toc-item md-toc-h3" data-ref="c40707"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c40707">设置异步回调处理对象 set_handler</a></span><span class="md-toc-item md-toc-h3" data-ref="c40734"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c40734">获取交易日 get_trading_days</a></span><span class="md-toc-item md-toc-h3" data-ref="c40763"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c40763">获取股票信息  get_stock_basicinfo</a></span><span class="md-toc-item md-toc-h3" data-ref="c40791"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c40791">获取复权因子 get_autype_list</a></span><span class="md-toc-item md-toc-h3" data-ref="c40826"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c40826">获取历史K线 get_history_kline</a></span><span class="md-toc-item md-toc-h3" data-ref="c40877"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c40877">获取市场快照 get_market_snapshot</a></span><span class="md-toc-item md-toc-h3" data-ref="c40928"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c40928">订阅 subscribe</a></span><span class="md-toc-item md-toc-h3" data-ref="c40957"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c40957">退订 unsubscribe</a></span><span class="md-toc-item md-toc-h3" data-ref="c40987"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c40987">查询订阅 query_subscription</a></span><span class="md-toc-item md-toc-h3" data-ref="c41000"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c41000">获取报价   get_stock_quote 和 StockQuoteHandlerBase</a></span><span class="md-toc-item md-toc-h3" data-ref="c41037"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c41037">获取逐笔   get_rt_ticker 和 TickerHandlerBase</a></span><span class="md-toc-item md-toc-h3" data-ref="c41092"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c41092">获取实时K线    get_cur_kline 和 CurKlineHandlerBase</a></span><span class="md-toc-item md-toc-h3" data-ref="c41129"><a class="md-toc-inner" style="cursor: pointer;" href="#header-c41129">获取摆盘   get_order_book 和 OrderBookHandlerBase</a></span></p></div><h1><a name='header-c40448' class='md-header-anchor '></a>接口概要</h1><p>开放接口基于PC客户端获取数据，提供给用户使用。</p><p>开放接口分为<strong>低频接口</strong>、<strong>订阅接口</strong>和<strong>高频接口</strong>，以及<strong>回调处理基类</strong>：</p><p></p><p><strong>低频接口</strong>主要用来获取股票市场静态和全局的数据，让用户得到股票的基本信息，不允许高频调用。</p><p>如果要实时获取数据，则需要调用高频接口。</p><p></p><p><strong>订阅接口</strong>是用来管理高频接口使用额度，包括订阅、退订和查询额度。</p><p><em>订阅</em>：在使用高频接口前，需要订阅想要的数据。订阅成功后，则可以使用高频接口获取；订阅各类数据有额度限制：</p><table><thead><tr><th>订阅数据</th><th>订阅额度</th></tr></thead><tbody><tr><td>K线</td><td>150</td></tr><tr><td>逐笔</td><td>5</td></tr><tr><td>报价</td><td>50</td></tr><tr><td>摆盘</td><td>50</td></tr></tbody></table><p><em>查询额度</em>：用来查询现在各项额度占用情况。用户可以看到每一种类型数据都有订阅了哪些股票；然后利用退订操作来去掉不需要的股票数据。</p><p><em>退订</em>：用户可以退订指定股票和指定数据类型，空出额度。</p><p><strong>如果数据不订阅，直接调用高频接口则会返回失败。</strong>
订阅时可选择推送选项。推送开启后，程序就会持续收到客户端推送过来的行情数据。用户可以通过继承<strong>回调处理基类</strong>，并实现用户自己的子类来使用数据推送功能。</p><p><strong>高频接口</strong>可以获取实时数据，可以针对小范围内的股票频繁调用；比如需要跟踪某个股票的逐笔和摆盘变化等；在调用之前需要将频繁获取的数据订阅注册。</p><p><strong>回调处理基类</strong>用于实现数据推送功能，用户在此基类上实现子类并实例化后，当客户端不断推送数据时，程序就会调用对应的对象处理。</p><p></p><h1><a name='header-c40495' class='md-header-anchor '></a>接口列表</h1><h2><a name='header-c40496' class='md-header-anchor '></a>上下文控制</h2><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">start</span>() &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-comment"># 开启异步数据接收</span></span></pre></div><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">stop</span>() &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-comment"># 停止异步数据接收</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">set_handler</span>(<span class="cm-variable">handler</span>) <span class="cm-comment"># 设置用于异步处理数据的回调对象</span></span></pre></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 115px;"></div></div></div></pre><h2><a name='header-c40498' class='md-header-anchor '></a>低频数据接口</h2><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">get_trading_days</span>(<span class="cm-variable">market</span>, <span class="cm-variable">start_date</span>=<span class="cm-builtin">None</span>, <span class="cm-variable">end_date</span>=<span class="cm-builtin">None</span>)  <span class="cm-comment"># 获取交易日</span></span></pre></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">get_stock_basicinfo</span>(<span class="cm-variable">market</span>, <span class="cm-variable">stock_type</span>=<span class="cm-string">'STOCK'</span>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-comment"># 获取股票信息</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">get_history_kline</span>(<span class="cm-variable">code</span>, <span class="cm-variable">start</span>=<span class="cm-builtin">None</span>, <span class="cm-variable">end</span>=<span class="cm-builtin">None</span>, <span class="cm-variable">ktype</span>=<span class="cm-string">'K_DAY'</span>, <span class="cm-variable">autype</span>=<span class="cm-string">'qfq'</span>)  <span class="cm-comment"># 获取历史K线</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">get_autype_list</span>(<span class="cm-variable">code_list</span>) &nbsp; &nbsp;  <span class="cm-comment"># 获取复权因子</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">get_market_snapshot</span>(<span class="cm-variable">code_list</span>)  <span class="cm-comment"># 获取市场快照</span></span></pre></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 115px;"></div></div></div></pre><h2><a name='header-c40500' class='md-header-anchor '></a>订阅接口</h2><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">subscribe</span>(<span class="cm-variable">stock_code</span>, <span class="cm-variable">data_type</span>, <span class="cm-variable">push</span>=<span class="cm-builtin">False</span>) <span class="cm-comment"># 订阅</span></span></pre></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">unsubscribe</span>(<span class="cm-variable">stock_code</span>, <span class="cm-variable">data_type</span>) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-comment"># 退订</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">query_subscription</span>() &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="cm-comment"># 查询订阅</span></span></pre></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 69px;"></div></div></div></pre><h2><a name='header-c40503' class='md-header-anchor '></a>高频数据接口</h2><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">get_stock_quote</span>(<span class="cm-variable">code_list</span>) <span class="cm-comment">#  获取报价</span></span></pre></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">get_rt_ticker</span>(<span class="cm-variable">code</span>, <span class="cm-variable">num</span>) &nbsp; <span class="cm-comment"># 获取逐笔</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">get_cur_kline</span>(<span class="cm-variable">code</span>, <span class="cm-variable">num</span>, <span class="cm-variable">ktype</span>=<span class="cm-string">' K_DAY'</span>, <span class="cm-variable">autype</span>=<span class="cm-string">'qfq'</span>) <span class="cm-comment"># 获取当前K线</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">get_order_book</span>(<span class="cm-variable">code</span>) &nbsp; &nbsp; &nbsp; <span class="cm-comment"># 获取摆盘</span></span></pre></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 92px;"></div></div></div></pre><h2><a name='header-c40505' class='md-header-anchor '></a>回调处理基类</h2><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">StockQuoteHandlerBase</span> <span class="cm-comment"># 报价处理基类</span></span></pre></div><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">OrderBookHandlerBase</span>  <span class="cm-comment"># 摆盘处理基类</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">CurKlineHandlerBase</span> &nbsp; <span class="cm-comment"># 实时K线处理基类</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">TickerHandlerBase</span> &nbsp; &nbsp; <span class="cm-comment"># 逐笔处理基类</span></span></pre></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 161px;"></div></div></div></pre><p></p><h1><a name='header-c40509' class='md-header-anchor '></a>接口说明</h1><h2><a name='header-c40511' class='md-header-anchor '></a>参数类型定义</h2><p><strong>市场标识</strong> market，（字符串类型）：</p><table><thead><tr><th>股票市场</th><th>标识</th></tr></thead><tbody><tr><td>港股</td><td>&quot;HK&quot;</td></tr><tr><td>美股</td><td>&quot;US&quot;</td></tr><tr><td>沪股</td><td>&quot;SH&quot;</td></tr><tr><td>深股</td><td>&quot;SZ&quot;</td></tr><tr><td>香港期货</td><td>&quot;HK_FUTURE&quot;</td></tr></tbody></table><p></p><p><strong>证券类型</strong> stock_type，（字符串类型）： </p><table><thead><tr><th>股票类型</th><th>标识</th></tr></thead><tbody><tr><td>正股</td><td>&quot;STOCK&quot;</td></tr><tr><td>指数</td><td>&quot;IDX&quot;</td></tr><tr><td>ETF基金</td><td>&quot;ETF&quot;</td></tr><tr><td>涡轮牛熊</td><td>&quot;WARRANT&quot;</td></tr><tr><td>债券</td><td>&quot;BOND&quot;</td></tr></tbody></table><p></p><p><strong>复权类型</strong>autype，（字符串类型）：</p><table><thead><tr><th>复权类型</th><th>标识</th></tr></thead><tbody><tr><td>前复权</td><td>&quot;qfq&quot;</td></tr><tr><td>后复权</td><td>&quot;hfq&quot;</td></tr><tr><td>不复权</td><td>None</td></tr></tbody></table><p></p><p><strong>K线类型</strong>，（字符串类型）：</p><table><thead><tr><th>K线类型</th><th>标识</th></tr></thead><tbody><tr><td>1分K</td><td>&quot;K_1M&quot;</td></tr><tr><td>5分K</td><td>&quot;K_5M&quot;</td></tr><tr><td>15分K</td><td>&quot;K_15M&quot;</td></tr><tr><td>30分K</td><td>&quot;K_30M&quot;</td></tr><tr><td>60分K</td><td>&quot;K_60M&quot;</td></tr><tr><td>日K</td><td>&quot;K_DAY&quot;</td></tr><tr><td>周K</td><td>&quot;K_WEEK&quot;</td></tr><tr><td>月K</td><td>&quot;K_MON&quot;</td></tr></tbody></table><p></p><p><strong>订阅数据类型</strong>，（字符串类型） </p><table><thead><tr><th>订阅类型</th><th>标识</th></tr></thead><tbody><tr><td>逐笔</td><td>&quot;TICKER&quot;</td></tr><tr><td>报价</td><td>&quot;QUOTE&quot;</td></tr><tr><td>摆盘</td><td>&quot;ORDER_BOOK&quot;</td></tr><tr><td>1分K</td><td>&quot;K_1M&quot;</td></tr><tr><td>5分K</td><td>&quot;K_5M&quot;</td></tr><tr><td>15分K</td><td>&quot;K_15M&quot;</td></tr><tr><td>30分K</td><td>&quot;K_30M&quot;</td></tr><tr><td>60分K</td><td>&quot;K_60M&quot;</td></tr><tr><td>日K</td><td>&quot;K_DAY&quot;</td></tr><tr><td>周K</td><td>&quot;K_WEEK&quot;</td></tr><tr><td>月K</td><td>&quot;K_MON&quot;</td></tr></tbody></table><p></p><p><strong>股票代码模式</strong>为：“ 市场+原始代码&quot;
例如，“HK.00700”, “SZ.000001”, “US.AAPL”</p><p></p><p><strong>注意，原始代码部分的字符串必须和客户端显示的完全匹配</strong>，比如：
腾讯为“HK.00700”，而不能是“HK.700”</p><p></p><p><strong>对于用户来说接口会返回两个值</strong>
ret_code：调用执行返回状态，0为成功，其它为失败
ret_data：</p><table><thead><tr><th>ret_code</th><th>ret_data</th></tr></thead><tbody><tr><td>成功</td><td>ret_data为实际数据</td></tr><tr><td>失败</td><td>ret_data为错误描述字符串</td></tr></tbody></table><p></p><p></p><h2><a name='header-c40677' class='md-header-anchor '></a>详细说明</h2><h3><a name='header-c40678' class='md-header-anchor '></a>实例化上下文对象</h3><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">quote_ctx</span> = <span class="cm-variable">OpenQuoteContext</span>(<span class="cm-variable">host</span>=<span class="cm-string">'127.0.0.1'</span>, <span class="cm-variable">sync_port</span>=<span class="cm-number">11111</span>, <span class="cm-variable">async_port</span>=<span class="cm-number">11111</span>)</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 23px;"></div></div></div></pre><p><strong>功能</strong>：创建上下文，建立网络连接
<strong>参数</strong>:
<strong>host</strong>：网络连接地址
<strong>sync_port</strong>：网络连接端口，用于同步通信。
<strong>async_port</strong>：网络连接端口，用于异步通信，接收客户端的数据推送。</p><p></p><p></p><h3><a name='header-c40691' class='md-header-anchor '></a>启动推送接收 start</h3><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">quote_ctx</span>.<span class="cm-property">start</span>()</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 23px;"></div></div></div></pre><p><strong>功能</strong>：启动推送接收线程，异步接收客户端推送的数据。</p><p></p><p></p><h3><a name='header-c40699' class='md-header-anchor '></a>停止推送接收 stop</h3><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">quote_ctx</span>.<span class="cm-property">stop</span>()</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 23px;"></div></div></div></pre><p><strong>功能</strong>：停止推送接收线程，不再接收客户端推送的数据。</p><p></p><p></p><h3><a name='header-c40707' class='md-header-anchor '></a>设置异步回调处理对象 set_handler</h3><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">quote_ctx</span>.<span class="cm-property">set_handler</span>(<span class="cm-variable">handler</span>)</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 23px;"></div></div></div></pre><p><strong>功能</strong>：设置回调处理对象，用于接收线程在收到数据后调用。用户应该将自己实现的回调对象设置，以便实现事件驱动。</p><p>handler必须是以下几种类的子类对象：</p><table><thead><tr><th>类名</th><th>说明</th></tr></thead><tbody><tr><td><strong>StockQuoteHandlerBase</strong></td><td>报价处理基类</td></tr><tr><td><strong>OrderBookHandlerBase</strong></td><td>摆盘处理基类</td></tr><tr><td><strong>CurKlineHandlerBase</strong></td><td>实时K线处理基类</td></tr><tr><td><strong>TickerHandlerBase</strong></td><td>逐笔处理基类</td></tr></tbody></table><p></p><p></p><h3><a name='header-c40734' class='md-header-anchor '></a>获取交易日 get_trading_days</h3><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>, <span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">get_trading_days</span>(<span class="cm-variable">market</span>, <span class="cm-variable">start_date</span>=<span class="cm-builtin">None</span>, <span class="cm-variable">end_date</span>=<span class="cm-builtin">None</span>)</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 23px;"></div></div></div></pre><p><strong>功能</strong>：取指定市场，某个日期时间段的交易日列表</p><p><strong>参数</strong>：
<strong>market</strong>: 市场标识
<strong>start_date</strong>: 起始日期;  string类型，格式YYYY-MM-DD，仅指定到日级别即可，默认值None表示最近一年前的日期
<strong>end_date</strong>: 结束日期;  string类型，格式YYYY-MM-DD，仅指定到日级别即可，取默认值None表示取当前日期</p><p><strong>返回</strong>：
ret_code失败时，ret_data返回为错误描述字符串；
客户端无数据时，ret_code为成功，ret_data返回None 
正常情况下，ret_data为日期列表（每个日期是string类型），如果指定时间段中无交易日，则ret_data为空列表。</p><p><strong>失败情况</strong>：</p><ol start='' ><li>市场标识不合法</li><li>起止日期输入不合法</li><li>客户端内部或网络错误</li></ol><p></p><h3><a name='header-c40763' class='md-header-anchor '></a>获取股票信息  get_stock_basicinfo</h3><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>, <span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">get_stock_basicinfo</span>(<span class="cm-variable">market</span>, <span class="cm-variable">stock_type</span>=<span class="cm-string">'STOCK'</span>)</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 23px;"></div></div></div></pre><p><strong>功能</strong>：取符合市场和股票类型条件的股票简要信息</p><p><strong>参数</strong>：
<strong>market</strong>: 市场标识, string，例如，”HK”，”US”；具体见市场标识说明
<strong>stock_type</strong>: 证券类型, string, 例如，”STOCK”，”ETF”；具体见证券类型说明</p><p><strong>返回</strong>：
ret_code失败时，ret_data返回为错误描述字符串；
客户端无符合条件数据时，ret_code为成功，ret_data返回None 
正常情况下，ret_data为一个dataframe，其中包括：
code：股票代码，string，例如： ”HK.00700”，“US.AAPL”
name：股票名称，string
lot_size：每手股数，int
stock_type：股票类型，string，例如： ”STOCK”，”ETF”</p><p><strong>失败情况</strong>：</p><ol start='' ><li>市场或股票类型不合法 </li><li>客户端内部或网络错误</li></ol><p></p><h3><a name='header-c40791' class='md-header-anchor '></a>获取复权因子 get_autype_list</h3><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>, <span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">get_autype_list</span>(<span class="cm-variable">code_list</span>)</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 23px;"></div></div></div></pre><p><strong>功能</strong>：获取复权因子数据 
<strong>参数</strong>：
<strong>code_list</strong>: 股票代码列表，例如，HK.00700，US.AAPL
<strong>返回</strong>：
ret_code失败时，ret_data返回为错误描述字符串；
客户端无符合条件数据时，ret_code为成功，ret_data返回None 
正常情况下，ret_data为一个dataframe，其中包括：
<strong>code</strong>：股票代码，string，例如： ”HK.00700”，“US.AAPL”
<strong>ex_div_date</strong>：除权除息日，string类型，格式YYYY-MM-DD 
<strong>split_ratio</strong>：拆合股比例 double，例如，对于5股合1股为1/5，对于1股拆5股为5/1
<strong>per_cash_div</strong>：每股派现；double
<strong>per_share_div_ratio</strong>：每股送股比例；	double
<strong>per_share_trans_ratio</strong>：每股转增股比例；	double
<strong>allotment_ratio</strong>：	每股配股比例；double
<strong>allotment_price</strong>：配股价；double
<strong>stk_spo_ratio</strong>： 增发比例：double
<strong>stk_spo_price</strong>  增发价格：double
<strong>forward_adj_factorA</strong>：前复权因子A；double
<strong>forward_adj_factorB</strong>：前复权因子B；double
<strong>backward_adj_factorA</strong>：后复权因子A；double
<strong>backward_adj_factorB</strong>：后复权因子B；double
返回数据中不一定包含所有codelist中的代码，调用方自己需要检查，哪些股票代码是没有返回复权数据的，未返回复权数据的股票说明没有找到相关信息。</p><p><strong>复权价格 = 复权因子A  * 价格 + 复权因子B</strong></p><p><strong>失败情况</strong>：
1．	Codelist中股票代码不合法
2．	客户端内部或网络错误</p><p></p><h3><a name='header-c40826' class='md-header-anchor '></a>获取历史K线 get_history_kline</h3><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>, <span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">get_history_kline</span>(<span class="cm-variable">code</span>, <span class="cm-variable">start</span>=<span class="cm-builtin">None</span>, <span class="cm-variable">end</span>=<span class="cm-builtin">None</span>, <span class="cm-variable">ktype</span>=<span class="cm-string">'K_DAY'</span>, <span class="cm-variable">autype</span>=<span class="cm-string">'qfq'</span>)</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 46px;"></div></div></div></pre><p><strong>功能</strong>： 获取指定股票K线历史数据
<strong>参数</strong>：
<strong>code</strong>：股票代码
<strong>start</strong> ：开始时间, string; YYYY-MM-DD；为空时取去当前时间;
<strong>end</strong>  ： 结束时间, string; YYYY-MM-DD；为空时取当前时间;
<strong>ktype</strong> ：k线类型，默认为日K
<strong>autype</strong>  复权类型，string；”qfq”-前复权，”hfq”-后复权，None-不复权，默认为”qfq”</p><p>开始结束时间按照闭区间查询，时间查询以k线时间time_key作为比较标准。即满足
start&lt;=Time_key&lt;=end条件的k线作为返回内容，k线时间time_key的设定标准在返回值中说明</p><p><strong>返回</strong>：
ret_code失败时，ret_data返回为错误描述字符串；
客户端无符合条件数据时，ret_code为成功，返回None </p><p>正常情况下返回K线数据为一个DataFrame包含:
<strong>code</strong>： 股票代码；string
<strong>time_key</strong>：  K线时间 string  “YYYY-MM-DD HH:mm:ss”
<strong>open</strong>： 开盘价；double
<strong>high</strong>： 最高价；double
<strong>close</strong>： 收盘价；double
<strong>low</strong>： 最低价：double
<strong>volume</strong>： 成交量；long
<strong>turnover</strong> ：成交额；double</p><p>对于日K线，time_key为当日时间具体到日，比如说2016-12-23日的日K，K线时间为” 2016-12-23 00:00:00”</p><p>对于分K线，time_key为当日时间具体到分，例如，
1分K，覆盖时间为9：35：00到9：35：59的分K，K线时间time_key为”2016-12-23 09:36:00”
5分K，覆盖时间为10：05：00到10：09：59的5分K，K线时间time_key为”2016-12-23 10:10:00”
15分K，覆盖时间为10：00：00到10：14：59的15分K，K线时间time_key为”2016-12-23 10:15:00”
30分K，覆盖时间为10：00：00到10：29：59的30分K，K线时间time_key为” 2016-12-23 10:30:00”
60分K，覆盖时间为10：30：00到11：29：59的60分K，K线时间time_key为” 2016-12-23 11:30:00”</p><p>对于周K线，12月19日到12月25日的周K线，K线时间time_key为” 2016-12-19 00:00:00” </p><p>对于月K线，12月的月K线时间time_key为” 2016-12-01 00:00:00”，即为当月1日时间</p><p><strong>失败情况</strong>:</p><ol start='' ><li>股票代码不合法</li><li>PLS接口返回错误 </li></ol><p></p><h3><a name='header-c40877' class='md-header-anchor '></a>获取市场快照 get_market_snapshot</h3><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>, <span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">get_market_snapshot</span>(<span class="cm-variable">code_list</span>):</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 23px;"></div></div></div></pre><p><strong>功能</strong>：一次性获取最近当前股票列表的快照数据（每日变化的信息），该接口对股票个数有限制，一次最多传入200只股票
<strong>参数</strong>：
<strong>code_list</strong>: 股票代码列表，例如，HK.00700，US.AAPL
传入的codelist只允许包含1种股票类型。
<strong>返回</strong>：
ret_code失败时，ret_data返回为错误描述字符串；
客户端无符合条件数据时，ret_code为成功，ret_data返回None 
正常情况下，ret_data为一个dataframe，其中包括：</p><p><strong>code</strong> ：股票代码；string
<strong>data_date</strong>：	交易日期(yyyy-MM-dd)；string
<strong>data_time</strong>：	交易时间&#39;HH:mm:ss&#39;；string
<strong>last_price</strong> ： 	 最新价格；double
<strong>open_price</strong>：	 今日开盘价；double
<strong>high_price</strong>：	 最高价格；double
<strong>low_price</strong>：	     最低价格；double
<strong>prev_close_price</strong>：	昨收盘价格；double
<strong>volume</strong>：	成交数量； long
<strong>turnover</strong>：	成交金额；double
<strong>turnover_rate</strong>：	换手率；double
<strong>amplitude</strong>：	  振幅；double 
<strong>suspension</strong>：	  是否停牌(True表示停牌)；bool
<strong>listing_date</strong> ：  上市日期 (yyyy-MM-dd)；string</p><p>返回DataFrame，包含上述字段</p><p>返回数据量不一定与codelist长度相等， 用户需要自己判断</p><p><strong>调用频率限制：</strong>
<strong>5s一次</strong></p><p><strong>失败情况</strong>:</p><ol start='' ><li>Codelist中股票代码不合法</li><li>Codelist长度超过规定数量</li><li>客户端内部或网络错误</li><li>传入的codelist包含多种股票类型</li></ol><p></p><h3><a name='header-c40928' class='md-header-anchor '></a>订阅 subscribe</h3><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>,<span class="cm-variable">ret_data</span>= <span class="cm-variable">quote_ctx</span>.<span class="cm-property">subscribe</span>(<span class="cm-variable">stock_code</span>, <span class="cm-variable">data_type</span>, <span class="cm-variable">push</span>=<span class="cm-builtin">False</span>) </span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 23px;"></div></div></div></pre><p><strong>功能</strong>：订阅注册需要的实时信息，指定股票和订阅的数据类型即可： 
<strong>参数</strong>：
<strong>stock_code</strong>: 需要订阅的股票代码
<strong>data_type</strong>: 需要订阅的数据类型
<strong>push</strong>: 推送选项，默认不推送
<strong>返回</strong>：
ret_code失败时，ret_data返回为错误描述字符串；
ret_code为成功，ret_data返回None 
如果指定内容已订阅，则直接返回成功</p><p><strong>失败情况</strong>:</p><ol start='' ><li>股票代码不合法，不存在</li><li>数据类型不合法</li><li>订阅额度已满，参考订阅额度表</li><li>客户端内部或网络错误</li></ol><p></p><h3><a name='header-c40957' class='md-header-anchor '></a>退订 unsubscribe</h3><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>,<span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">unsubscribe</span>(<span class="cm-variable">stock_code</span>, <span class="cm-variable">data_type</span>) </span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 23px;"></div></div></div></pre><p>ret_code,ret_data = unsubscribe(stock_code, data_type) 
<strong>功能</strong>：退订注册的实时信息，指定股票和订阅的数据类型即可： 
<strong>参数</strong>：
<strong>stock_code</strong>: 需要退订的股票代码
<strong>data_type</strong>: 需要退订的数据类型</p><p><strong>返回</strong>：
ret_code失败时，ret_data返回为错误描述字符串；
ret_code为成功，ret_data返回None 
如果指定内容已退订，则直接返回成功</p><p><strong>失败情况</strong>:</p><ol start='' ><li>股票代码不合法，不存在</li><li>数据类型不合法</li><li>内容订阅后不超过60s，就退订</li><li>客户端内部或网络错误</li></ol><p></p><h3><a name='header-c40987' class='md-header-anchor '></a>查询订阅 query_subscription</h3><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">query_subscription</span>() </span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 23px;"></div></div></div></pre><p><strong>功能</strong>：查询已订阅的实时信息
<strong>返回</strong>：
字典类型，已订阅类型为主键，值为订阅该类型的股票，例如</p><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;">{ <span class="cm-error">‘</span><span class="cm-variable">QUOTE</span><span class="cm-error">’</span>: [<span class="cm-error">‘</span><span class="cm-variable">HK</span><span class="cm-number">.00700</span><span class="cm-error">’</span>, <span class="cm-error">‘</span><span class="cm-variable">SZ</span><span class="cm-number">.000001</span><span class="cm-error">’</span>]</span></pre></div><pre class=""><span style="padding-right: 0.1px;">  <span class="cm-error">‘</span><span class="cm-variable">TICKER</span><span class="cm-error">’</span>: [<span class="cm-error">‘</span><span class="cm-variable">HK</span><span class="cm-number">.00700</span><span class="cm-error">’</span>]</span></pre><pre class=""><span style="padding-right: 0.1px;">  <span class="cm-error">‘</span><span class="cm-variable">K_1M</span><span class="cm-error">’</span>: [<span class="cm-error">‘</span><span class="cm-variable">HK</span><span class="cm-number">.00700</span><span class="cm-error">’</span>]</span></pre><pre class=""><span style="padding-right: 0.1px;">  <span class="cm-comment">#无股票订阅摆盘和其它类型分K</span></span></pre><pre class=""><span style="padding-right: 0.1px;">}</span></pre></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 115px;"></div></div></div></pre><p><strong>失败情况</strong>:
客户端内部或网络错误</p><p></p><h3><a name='header-c41000' class='md-header-anchor '></a>获取报价   get_stock_quote 和 StockQuoteHandlerBase</h3><p>对于同步请求使用<strong>get_stock_quote</strong>直接得到报价</p><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>, <span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">get_stock_quote</span>(<span class="cm-variable">code_list</span>)</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 23px;"></div></div></div></pre><p><strong>功能</strong>：获取订阅股票报价的实时数据，有订阅要求限制 
<strong>参数</strong>：
<strong>code_list</strong>: 股票代码列表，例如，HK.00700，US.AAPL
传入的codelist只允许包含1种股票类型的股票。
必须确保code_list中的股票均订阅成功后才能够执行
<strong>返回</strong>：
ret_code失败时，ret_data返回为错误描述字符串；
客户端无符合条件数据时，ret_code为成功，返回None 
正常情况下，ret_data为一个dataframe，其结构和get_market_snapshot一样</p><p><strong>失败情况</strong>:</p><ol start='' ><li>codelist中股票代码不合法</li><li>codelist包含未对QUOTE类型订阅的股票</li><li>客户端内部或网络错误</li><li>传入的codelist包含多种股票类型</li></ol><p>对于异步推送数据需要使用<strong>StockQuoteHandlerBase</strong>以及继承它的子类处理。例如：</p><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;"> &nbsp;  <span class="cm-keyword">class</span> <span class="cm-def">StockQuoteTest</span>(<span class="cm-variable">StockQuoteHandlerBase</span>):</span></pre></div><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">def</span> <span class="cm-def">on_recv_rsp</span>(<span class="cm-variable-2">self</span>, <span class="cm-variable">rsp_str</span>):</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-variable">ret_code</span>, <span class="cm-variable">content</span> = <span class="cm-builtin">super</span>().<span class="cm-property">on_recv_rsp</span>(<span class="cm-variable">rsp_str</span>) <span class="cm-comment"># 基类的on_recv_rsp方法解包返回了报价信息，格式与get_stock_quote一样</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">if</span> <span class="cm-variable">ret_code</span> <span class="cm-operator">!</span>= <span class="cm-variable">RET_OK</span>:</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">print</span>(<span class="cm-string">"StockQuoteTest: error, msg: %s"</span> <span class="cm-operator">%</span> <span class="cm-variable">content</span>)</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">return</span> <span class="cm-variable">RET_ERROR</span>, <span class="cm-variable">content</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  </span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">print</span>(<span class="cm-string">"StockQuoteTest "</span>, <span class="cm-variable">content</span>) <span class="cm-comment"># StockQuoteTest自己的处理逻辑</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  </span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">return</span> <span class="cm-variable">RET_OK</span>, <span class="cm-variable">content</span></span></pre></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 253px;"></div></div></div></pre><p></p><p></p><h3><a name='header-c41037' class='md-header-anchor '></a>获取逐笔   get_rt_ticker 和 TickerHandlerBase</h3><p>对于同步请求使用<strong>get_rt_ticker</strong>直接得到逐笔</p><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>, <span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">get_rt_ticker</span>(<span class="cm-variable">code</span>, , <span class="cm-variable">num</span>=<span class="cm-number">500</span>)</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 23px;"></div></div></div></pre><p><strong>功能</strong>： 获取指定股票的实时逐笔。取最近num个逐笔，
<strong>参数</strong>：
<strong>code</strong>: 股票代码，例如，HK.00700，US.AAPL
<strong>num</strong>: 最近ticker个数(有最大个数限制，最近500个）
<strong>返回</strong>：
ret_code失败时，ret_data为错误描述字符串；
客户端无符合条件数据时，ret为成功，ret_data返回None
通常情况下，返回DataFrame，DataFrame每一行是一个逐笔记录，包含：
<strong>stock_code</strong> 股票代码
<strong>sequence</strong> 逐笔序号
<strong>time</strong> 成交时间；string 
<strong>price</strong> 成交价格；double
<strong>volume</strong> 成交数量（股数）；int
<strong>turnover</strong> 成交金额；double
<strong>ticker_direction</strong> 逐笔方向；int</p><p>ticker_direction:</p><table><thead><tr><th>逐笔标识</th><th>说明</th></tr></thead><tbody><tr><td>TT_BUY</td><td>外盘</td></tr><tr><td>TT_ASK</td><td>内盘</td></tr><tr><td>TT_NEUTRAL</td><td>中性盘</td></tr></tbody></table><p>返回的逐笔记录个数不一定与num指定的相等，客户端只会返回自己有的数据。</p><p><strong>失败情况</strong>：</p><ol start='' ><li>code不合法</li><li>code是未对TICKER类型订阅的股票</li><li>客户端内部或网络错误</li></ol><p>对于异步推送数据需要使用<strong>TickerHandlerBase</strong>以及继承它的子类处理。例如：</p><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;"> &nbsp;  <span class="cm-keyword">class</span> <span class="cm-def">TickerTest</span>(<span class="cm-variable">TickerHandlerBase</span>):</span></pre></div><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">def</span> <span class="cm-def">on_recv_rsp</span>(<span class="cm-variable-2">self</span>, <span class="cm-variable">rsp_str</span>):</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-variable">ret_code</span>, <span class="cm-variable">content</span> = <span class="cm-builtin">super</span>().<span class="cm-property">on_recv_rsp</span>(<span class="cm-variable">rsp_str</span>) <span class="cm-comment"># 基类的on_recv_rsp方法解包返回了逐笔信息，格式与get_rt_ticker一样</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">if</span> <span class="cm-variable">ret_code</span> <span class="cm-operator">!</span>= <span class="cm-variable">RET_OK</span>:</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">print</span>(<span class="cm-string">"TickerTest: error, msg: %s"</span> <span class="cm-operator">%</span> <span class="cm-variable">content</span>)</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">return</span> <span class="cm-variable">RET_ERROR</span>, <span class="cm-variable">content</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">print</span>(<span class="cm-string">"TickerTest"</span>, <span class="cm-variable">content</span>)  <span class="cm-comment"># StockQuoteTest自己的处理逻辑</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">return</span> <span class="cm-variable">RET_OK</span>, <span class="cm-variable">content</span></span></pre></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 207px;"></div></div></div></pre><p></p><h3><a name='header-c41092' class='md-header-anchor '></a>获取实时K线    get_cur_kline 和 CurKlineHandlerBase</h3><p>对于同步请求使用<strong>get_cur_kline</strong>直接得到实时K线</p><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>, <span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">get_cur_kline</span>(<span class="cm-variable">code</span>, <span class="cm-variable">num</span>, <span class="cm-variable">ktype</span>=<span class="cm-string">'K_DAY'</span>, <span class="cm-variable">autype</span>=<span class="cm-string">'qfq'</span>)</span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 23px;"></div></div></div></pre><p></p><p><strong>功能</strong>： 实时获取指定股票最近num个K线数据，最多1000根
<strong>参数</strong>：
<strong>code</strong> 股票代码
<strong>ktype</strong> k线类型，和get_history_kline一样
<strong>autype</strong>  复权类型，string；qfq-前复权，hfq-后复权，None-不复权，默认为qfq</p><p>对于实时K线数据最多取最近1000根</p><p><strong>返回</strong>：
ret_code失败时，ret_data为错误描述字符串；
客户端无符合条件数据时，ret为成功，ret_data返回None
通常情况下，返回DataFrame，DataFrame内容和get_history_kline一样</p><p><strong>失败情况</strong>：</p><ol start='' ><li>code不合法</li><li>该股票未对指定K线类型订阅</li><li>客户端内部或网络错误</li></ol><p>对于异步推送数据需要使用<strong>CurKlineHandlerBase</strong>以及继承它的子类处理。例如：</p><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;"> &nbsp;  <span class="cm-keyword">class</span> <span class="cm-def">CurKlineTest</span>(<span class="cm-variable">CurKlineHandlerBase</span>):</span></pre></div><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">def</span> <span class="cm-def">on_recv_rsp</span>(<span class="cm-variable-2">self</span>, <span class="cm-variable">rsp_str</span>):</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-variable">ret_code</span>, <span class="cm-variable">content</span> = <span class="cm-builtin">super</span>().<span class="cm-property">on_recv_rsp</span>(<span class="cm-variable">rsp_str</span>) <span class="cm-comment"># 基类的on_recv_rsp方法解包返回了实时K线信息，格式除了与get_cur_kline所有字段外，还包含K线类型k_type</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">if</span> <span class="cm-variable">ret_code</span> <span class="cm-operator">!</span>= <span class="cm-variable">RET_OK</span>:</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">print</span>(<span class="cm-string">"CurKlineTest: error, msg: %s"</span> <span class="cm-operator">%</span> <span class="cm-variable">content</span>)</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">return</span> <span class="cm-variable">RET_ERROR</span>, <span class="cm-variable">content</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">print</span>(<span class="cm-string">"CurKlineTest"</span>, <span class="cm-variable">content</span>) <span class="cm-comment"># CurKlineTest自己的处理逻辑</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">return</span> <span class="cm-variable">RET_OK</span>, <span class="cm-variable">content</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  </span></pre></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 207px;"></div></div></div></pre><p></p><h3><a name='header-c41129' class='md-header-anchor '></a>获取摆盘   get_order_book 和 OrderBookHandlerBase</h3><p>对于同步请求使用<strong>get_order_book</strong>直接得到摆盘</p><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;"><span class="cm-variable">ret_code</span>, <span class="cm-variable">ret_data</span> = <span class="cm-variable">quote_ctx</span>.<span class="cm-property">get_order_book</span>(<span class="cm-variable">code</span>) </span></pre></div></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 23px;"></div></div></div></pre><p><strong>功能</strong>：获取实时摆盘数据
<strong>参数</strong>：
<strong>code</strong>: 股票代码，例如，HK.00700，US.AAPL
<strong>返回</strong>：
ret_code失败时，ret_data为错误描述字符串；
客户端无符合条件数据时，ret为成功，ret_data返回None
通常情况下，返回字典</p><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;">{<span class="cm-error">‘</span><span class="cm-variable">stock_code</span><span class="cm-error">’</span>: <span class="cm-variable">stock_code</span></span></pre></div><pre class=""><span style="padding-right: 0.1px;"> <span class="cm-error">‘</span><span class="cm-variable">Ask</span><span class="cm-error">’</span>:[ (<span class="cm-variable">ask_price1</span>, <span class="cm-variable">ask_volume1</span><span class="cm-error">，</span><span class="cm-variable">order_num</span>), (<span class="cm-variable">ask_price2</span>, <span class="cm-variable">ask_volume2</span>, <span class="cm-variable">order_num</span>),<span class="cm-error">…</span>]</span></pre><pre class=""><span style="padding-right: 0.1px;"><span class="cm-error">‘</span><span class="cm-variable">Bid</span><span class="cm-error">’</span>: [ (<span class="cm-variable">bid_price1</span>, <span class="cm-variable">bid_volume1</span>, <span class="cm-variable">order_num</span>), (<span class="cm-variable">bid_price2</span>, <span class="cm-variable">bid_volume2</span>, <span class="cm-variable">order_num</span>),<span class="cm-error">…</span>]</span></pre><pre class=""><span style="padding-right: 0.1px;">}</span></pre></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 92px;"></div></div></div></pre><p><strong>失败情况</strong>：</p><ol start='' ><li>code不合法</li><li>该股票未对ORDER_BOOK类型订阅</li><li>客户端内部或网络错误</li></ol><p>对于异步推送数据需要使用<strong>OrderBookHandlerBase</strong>以及继承它的子类处理。例如：</p><pre class="md-fences md-end-block" lang="python"> <div class="CodeMirror cm-s-inner CodeMirror-wrap"><div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 0px; left: 4px;"></div><div class="CodeMirror-hscrollbar" style="left: 0px;"><div style="height: 100%; min-height: 1px; width: 0px;"></div></div><div class="CodeMirror-vscrollbar"><div style="min-width: 1px; height: 0px;"></div></div><div class="CodeMirror-scrollbar-filler"></div><div class="CodeMirror-gutter-filler"></div><div class="CodeMirror-scroll" tabindex="-1"><div class="CodeMirror-sizer" style="margin-left: 0px; min-height: 0px;"><div style="position: relative; top: 0px;"><div class="CodeMirror-lines"><div style="position: relative; outline: none;"><div class="CodeMirror-measure"><pre><span>xxxxxxxxxx</span></pre></div><div class="CodeMirror-measure"></div><div style="position: relative; z-index: 1;"></div><div class="CodeMirror-code"><div class="CodeMirror-activeline" style="position: relative;"><div class="CodeMirror-activeline-background CodeMirror-linebackground"></div><pre class=""><span style="padding-right: 0.1px;"><span>​</span></span></pre></div><pre class=""><span style="padding-right: 0.1px;"> &nbsp;  <span class="cm-keyword">class</span> <span class="cm-def">OrderBookTest</span>(<span class="cm-variable">OrderBookHandlerBase</span>):</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">def</span> <span class="cm-def">on_recv_rsp</span>(<span class="cm-variable-2">self</span>, <span class="cm-variable">rsp_str</span>):</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-variable">ret_code</span>, <span class="cm-variable">content</span> = <span class="cm-builtin">super</span>().<span class="cm-property">on_recv_rsp</span>(<span class="cm-variable">rsp_str</span>) <span class="cm-comment"># 基类的on_recv_rsp方法解包返回了实时K线信息，格式与get_order_book一样</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">if</span> <span class="cm-variable">ret_code</span> <span class="cm-operator">!</span>= <span class="cm-variable">RET_OK</span>:</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">print</span>(<span class="cm-string">"OrderBookTest: error, msg: %s"</span> <span class="cm-operator">%</span> <span class="cm-variable">content</span>)</span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">return</span> <span class="cm-variable">RET_ERROR</span>, <span class="cm-variable">content</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">print</span>(<span class="cm-string">"OrderBookTest"</span>, <span class="cm-variable">content</span>) <span class="cm-comment"># OrderBookTest自己的处理逻辑</span></span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <span class="cm-keyword">return</span> <span class="cm-variable">RET_OK</span>, <span class="cm-variable">content</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  </span></pre><pre class=""><span style="padding-right: 0.1px;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  </span></pre></div></div></div></div></div><div style="position: absolute; height: 30px; width: 1px; top: 0px;"></div><div class="CodeMirror-gutters" style="display: none; height: 253px;"></div></div></div></pre><p></p><p></p></div>
</body>
</html>